package mest.controller.Modeling;

import com.alibaba.fastjson.JSON;
import mest.entity.apart_file;
import mest.entity.car_file;
import mest.service.Modeling.IapartFileService;
import mest.service.Modeling.IcarFileService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description
 * @auther Machenike
 * @create 2019-11-15 23:07
 */

@RestController
@CrossOrigin
@RequestMapping(value = "/carFile")
public class carFile {
    @Resource
    private IcarFileService icfs;

    @RequestMapping(value="/insert")
    public String insert(car_file cf ){
        int i = icfs.insertCarFile(cf);

        if (i >= 1)
            return JSON.toJSONString("添加成功");
        else
            return JSON.toJSONString("添加失败");
    }
    @RequestMapping(value = "/baseSelect", produces = {"application/json;charset=utf-8", "text/plain;charset=utf-8"})
    public String baseSelect(int index,int pageSize) {

        List<car_file> carFilePage = icfs.findCarFilePage(index, pageSize);
        int i = icfs.selectCount();
        Map map  = new HashMap();
        map.put("code",0);
        map.put("msg","");
        map.put("count",i);
        map.put("data",carFilePage);
        return JSON.toJSONString(map);
    }



}
